@using Microsoft.AspNetCore.Identity
@using Microsoft.Extensions.Options
@using OrchardCore.Admin
@using OrchardCore.Entities
@using OrchardCore.Settings
@using OrchardCore.Users
@using OrchardCore.Users.Models
@inject ISiteService SiteService
@inject SignInManager<IUser> SignInManager
@inject IOptions<AdminOptions> AdminOptions

@{
    var allowChangeEmail = (await SiteService.GetSiteSettingsAsync()).As<ChangeEmailSettings>().AllowChangeEmail;
    var externalAuthenticationSchemes = await SignInManager.GetExternalAuthenticationSchemesAsync();
}
<ul class="navbar-nav">
    @if (User.Identity.IsAuthenticated)
    {
        <li class="nav-item dropdown">
            <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user fa-fw"></i> @User.Identity.Name<b class="caret"></b></a>
            <div class="dropdown-menu">
                <a class="dropdown-item" asp-route-area="OrchardCore.Admin" asp-controller="Admin" asp-action="Index"><i class="fa fa-desktop fa-fw"></i> @T["Dashboard"]</a>
                @if (allowChangeEmail)
                {
                    <a class="dropdown-item" asp-route-area="OrchardCore.Users" asp-controller="ChangeEmail" asp-action="Index"><i class="fa fa-envelope fa-fw"></i> @T["Change Email"]</a>
                }
                <a class="dropdown-item" asp-route-area="OrchardCore.Users" asp-controller="Account" asp-action="ChangePassword"><i class="fa fa-lock fa-fw"></i> @T["Change Password"]</a>
                @if (externalAuthenticationSchemes.Count() > 0)
                {
                    <a class="dropdown-item" asp-route-area="OrchardCore.Users" asp-controller="Account" asp-action="ExternalLogins"><i class="fa fa-user-lock fa-fw"></i> @T["External Logins"]</a>
                }
                <form class="form-inline" asp-route-area="OrchardCore.Users" asp-controller="Account" asp-action="LogOff" method="post">
                    <button type="submit" class="btn btn-link navbar-btn dropdown-item"><i class="fa fa-sign-out-alt fa-fw"></i> @T["Log off"]</button>
                </form>
            </div>
        </li>
    }
    else
    {
        <li class="nav-item"><a class="nav-link" asp-route-area="OrchardCore.Users" asp-controller="Account" asp-action="Login"><i class="fa fa-sign-in-alt fa-fw"></i> @T["Log in"]</a></li>
    }
</ul>